/*******************************************************************************
 * Copyright (c) 2010, 2030 www.itlaobing.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.shopping.service;

import java.sql.SQLException;

import cn.itlaobing.shopping.dao.UserDao;
import cn.itlaobing.shopping.exception.BusinessExceeption;
import cn.itlaobing.shopping.model.UserModel;

/** 
 * ClassName: UserService <br/> 
 * Function: 用户业务类<br/> 
 * date: 2017年11月1日 上午10:34:43 <br/> 
 * 
 * @author 王建蕊 
 * @version 1.0 
 * @since JDK 1.8 
 */
public class UserService {
	private UserDao ud=new UserDao();
	/** 
	 * login:(用户登录). <br/>
	 * 
	 * @author Administrator 
	 * @param username
	 * @param userpwd
	 * @return
	 * @throws BusinessExceeption 
	 * @since JDK 1.8 
	 */  
	public UserModel login(String username,String userpwd)throws BusinessExceeption{
		UserModel um=null;
		try {
			um=ud.login(username, userpwd);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			throw new BusinessExceeption(e.getMessage());
		} catch (SQLException e) {
			e.printStackTrace();
			throw new BusinessExceeption(e.getMessage());
		}finally {
			try {
				ud.close();
			} catch (SQLException e) {
				e.printStackTrace();
				throw new BusinessExceeption(e.getMessage());
			}
		}
		return um;
	}
}
